/**
 * @param {number[]} nums
 * @return {number[]}
 */
 var recoverArray = function(nums) {
  const n = nums.length/2
  nums.sort((a,b) => a-b)
  let total = nums.reduce((pre,cur) => pre+cur, 0)
  let max = nums[2*n-1]
  const check = (sum,dif) => {
    if(dif > 0 && dif % 2 !== 0) return false
    if((total - 2*sum)/n !== dif) return false
    return true
  }
  let ans = []
  const dfs = (idx, low, sum) => {
    if(ans.length > 0) return
    if(low.length === n){
      let last = low[n-1]
      let dif = max-last
      if(check(sum, dif)){
        ans = low.map(v => v+(dif/2))
      }
      return
    }
    for(let i = idx+1; i<2*n-1; i++){
      dfs(i, [...low,nums[i]], sum+nums[i])
    }
  }
  dfs(0, [nums[0]], nums[0])
  return ans
};